import { createApp } from 'vue';
import '@/assets/scss/base.scss';
import 'animate.css';
import 'element-plus/theme-chalk/el-loading.css'; //手动引入element-plus样式，解决message和loading组件能出现在节点中，但不显示的问题
import 'element-plus/theme-chalk/el-message.css'; //手动引入element-plus样式，解决message和loading组件能出现在节点中，但不显示的问题
import 'element-plus/theme-chalk/el-notification.css';
import 'element-plus/theme-chalk/el-message-box.css';
import 'element-plus/theme-chalk/el-table.css';

import App from './App.vue';
import mitt from 'mitt';
import router from './router/index';
import { createPinia } from 'pinia';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import GlobleDialog from '@/components/dialog/Index.vue';
import GlobleForm from '@/components/form/Index.vue';
import GlobleLinearBorder from '@/components/linearBorder/Index.vue';

const globleComponents = [
  { name: 'GlobleDialog', component: GlobleDialog },
  { name: 'GlobleForm', component: GlobleForm },
  { name: 'GlobleLinearBorder', component: GlobleLinearBorder },
];
const Mit = mitt();
const app = createApp(App);

//注册全部 icon图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}
for (const item of globleComponents) {
  app.component(item.name, item.component);
}

app.use(router);

const store = createPinia();
app.use(store);

// 定义全局变量  app.config.globalProperties.$变量名
app.config.globalProperties.$Bus = Mit;

//给vue声明定义的变量或函数，否则会报错没提示  declare module 'vue' 或 declare module '@vue/runtime-core'
declare module 'vue' {
  export interface ComponentCustomProperties {
    $Bus: typeof Mit;
  }
}

app.mount('#app');
